home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 12: Textmags & Docs / nf_archive_12.iso / MAGS / SOURCES / ATARI_SRC.ZIP / atari source / AHDI / IDEDRVR / TSTBOOT.S < prev   
Encoding:
Text File  |  2001-02-09  |  4.5 KB  |  200 lines

  1. ;+
  2. ; Tstboot.s - Scan all ACSI, SCSI and IDE-AT devices and attempt 
  3. ;        to boot from them.
  4. ;-
  5.  
  6.     .globl    _dmaread
  7.     .globl    _dmawrite
  8.  
  9. .data
  10. msg0:    dc.b    'In Tstboot.prg',13,10,0
  11. .even
  12. msg1:    dc.b    'Read sector 0 fails',13,10,0
  13. .even
  14. msg2:    dc.b    'Read sector 0 successes',13,10,0
  15. .even
  16. msg3:    dc.b    'Write last sector fails',13,10,0
  17. .even
  18. msg4:    dc.b    'Write last sector successes',13,10,0
  19. .even
  20. msg5:    dc.b    'Read last sector fails',13,10,0
  21. .even
  22. msg6:    dc.b    'Read last sector successes',13,10,0
  23. .even
  24. msg7:    dc.b    'Data matches',13,10,0
  25. .even
  26. msg8:    dc.b    'Data does not match',13,10,0
  27. .even
  28.  
  29. .text    
  30. tbstart:
  31.     clr.l    -(sp)
  32.     move.w    #$20,-(sp)
  33.     trap    #1
  34.     addq.l    #6,sp
  35.     move.l    d0,ostack    ; ostack = old stack value
  36.     
  37. ;    moveq    #8,d4        ; start with SCSI unit 0
  38. ;    moveq    #0,d4        ; start with ACSI unit 0
  39. tb0:    
  40.     pea    msg0        ; Entering program!
  41.     move.w    #9,-(sp)
  42.     trap    #1
  43.     addq.l    #6,sp        ; clean up stack
  44.     
  45.                 ; Reading sector 0
  46. ;    move.w    d4,-(sp)    ; dev #
  47.     move.w    #$10,-(sp)    ; AT unit 0
  48.     move.l    #buf,-(sp)    ; buffer address
  49.     move.w    #1,-(sp)    ; 1 sector
  50.     move.l    #0,-(sp)    ; sector 0
  51.     bsr    _dmaread    ; _dmaread()
  52.     add.l    #12,sp        ; clean up stack
  53.     tst.w    d0        ; successful?
  54.     beq    tb1        ; if yes -> more testing
  55.                 ; if no, quit
  56.     pea    msg1        ; fail on reading sector 0
  57.     move.w    #9,-(sp)
  58.     trap    #1
  59.     addq.l    #6,sp        ; clean up stack
  60.     bra    tbend
  61.  
  62. ;+    
  63. ;    cmpi.w    #8,d4        ; else, ACSI units scanned?
  64. ;    blt    tbend        ; yes - no bootable unit - done
  65. ;    moveq    #0,d4        ; else, start with ACSI unit 0
  66. ;    bra    tb0
  67. ;-
  68.  
  69. tb1:    pea    msg2        ; success on reading sector 0
  70.     move.w    #9,-(sp)
  71.     trap    #1
  72.     addq.l    #6,sp        ; clean up stack
  73.  
  74. ;+
  75.                 ; Writing to last sector
  76.     lea    buf,a0        ; a0 -> buf
  77.     move.l    $1c2(a0),d1    ; d1 = hard disk size
  78.     subq.l    #1,d1        ; d1 = last sector
  79.     move.l    d1,-(sp)    ; save sector number
  80. ;    move.w    d4,-(sp)    ; dev #
  81.     move.w    #$10,-(sp)    ; AT unit 0
  82.     move.l    a0,-(sp)    ; buffer address
  83.     move.w    #1,-(sp)    ; 1 sector
  84.     move.l    d1,-(sp)    ; last sector
  85.     bsr    _dmawrite    ; _dmawrite()
  86.     add.l    #12,sp        ; clean up stack
  87.     move.l    (sp)+,d1    ; restore sector number
  88.     tst.w    d0        ; successful?
  89.     beq    tb3        ; if yes - more testing
  90.                 ; if no - quit    
  91.     pea    msg3        ; fail on writing last sector
  92.     move.w    #9,-(sp)
  93.     trap    #1
  94.     addq.l    #6,sp        ; clean up stack
  95.     bra    tbend
  96.  
  97. tb3:    pea    msg4        ; success on writing last sector
  98.     move.w    #9,-(sp)
  99.     trap    #1
  100.     addq.l    #6,sp        ; clean up stack
  101.     
  102.                 ; Reading last sector
  103. ;    move.w    d4,-(sp)    ; dev #
  104.     move.w    #$10,-(sp)    ; AT unit 0
  105.     move.l    #buf2,-(sp)    ; buffer address
  106.     move.w    #1,-(sp)    ; 1 sector
  107.     move.l    d1,-(sp)    ; last sector
  108.     bsr    _dmaread    ; _dmaread()
  109.     add.l    #12,sp        ; clean up stack
  110.     tst.w    d0        ; successful?
  111.     beq    tb2        ; if yes - more testing
  112.                 ; if no - quit    
  113.     pea    msg5        ; fail on reading last sector
  114.     move.w    #9,-(sp)
  115.     trap    #1
  116.     addq.l    #6,sp        ; clean up stack
  117.     bra    tbend
  118.  
  119. tb2:    pea    msg6        ; success on reading last sector
  120.     move.w    #9,-(sp)
  121.     trap    #1
  122.     addq.l    #6,sp        ; clean up stack
  123.     
  124.                 ; compare data read with data written
  125.     moveq    #63,d0        ; dbra like one less
  126.     lea    buf,a0
  127.     lea    buf2,a1
  128. tb4:    cmpm.l    (a0)+,(a1)+
  129.     bne    tb5
  130.     dbra    d0,tb4
  131.  
  132.     pea    msg7        ; all data matches
  133.     move.w    #9,-(sp)
  134.     trap    #1
  135.     addq.l    #6,sp        ; clean up stack
  136.     bra    tbend
  137.  
  138. tb5:    pea    msg8        ; data read differs from data written
  139.     move.w    #9,-(sp)
  140.     trap    #1
  141.     addq.l    #6,sp        ; clean up stack
  142. ;-
  143.  
  144.  
  145. ;+
  146. ;    move.w    #$0ff,d0    ; checksum $100 words
  147. ;    moveq    #0,d1        ; d1 = 0; initialise sum
  148. ;    movea.l    _dskbufp,a0    ; a0 -> root sector image
  149. ;    adda.l    #$200,a0
  150. ;    movea.l    a0,a1        ; a1 -> root sector image
  151. ;tb2:    add.w    (a0)+,d1    ; add next word
  152. ;    dbra    d0,tb2        ; until all words are added
  153. ;    
  154. ;    cmpi.w    #$1234,d1    ; sum ?= magic number $1234
  155. ;    beq    tb3        ; yes - continue boot process
  156. ;
  157. ;    pea    msg3        ; print announcement
  158. ;    move.w    #9,-(sp)
  159. ;    trap    #1
  160. ;    addq.w    #6,sp        ; clean up stack
  161. ;    
  162. ;    addq.w    #1,d4        ; else, try next unit
  163. ;    bra    tb0
  164. ;    
  165. ;tb3:    pea    msg4        ; print announcement
  166. ;    move.w    #9,-(sp)
  167. ;    trap    #1
  168. ;    addq    #6,sp        ; clean up stack
  169. ;
  170. ;    movea.l    4(sp),a0    ; a0 -> basepage
  171. ;    move.l    $c(a0),d0    ; d0 = size of text
  172. ;    add.l    $14(a0),d0    ; d0 = size of (text + data)
  173. ;    add.l    $1c(a0),d0    ; d0 = size of (text + data + bss)
  174. ;    add.l    #$0100,d0    ; d0 = size of (text + data + bss + basepage)
  175. ;    move.l    d0,-(sp)    ; new size
  176. ;    move.l    a0,-(sp)    ; -> basepage
  177. ;    clr.w    -(sp)        ; WORD 0
  178. ;    move.w    #$4a,-(sp)    ; Mshrink()
  179. ;    trap    #1
  180. ;    adda    #12,sp
  181. ;    
  182. ;    move.l    #$444d4172,d3    ; d3 = "DMAr"
  183. ;    moveq    #0,d5        ; no user-preference
  184. ;    jsr    (a1)        ; continue boot process
  185. ;-
  186.     
  187. tbend:    move.l    ostack,-(sp)
  188.     move.w    #$20,-(sp)
  189.     trap    #1
  190.     addq.l    #6,sp
  191.     
  192.     clr.w    -(sp)        ; Pterm0()
  193.     trap    #1
  194.     illegal
  195.  
  196. .bss
  197. ostack:    ds.l    1
  198. buf:    ds.b    512
  199. buf2:    ds.b    512
  200. tbkeep: